package com.group01.validation;

import com.group01.annotation.CommodityType;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CommodityTypeValidation implements ConstraintValidator<CommodityType, String> {


    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        String regex = "^[0-9]+$";

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(value);

        return matcher.matches();
    }
}
